import importlib


class Config():

    def load_config(self, module_name):
        module = importlib.import_module(module_name)
        for key in dir(module):
            if key[0] != '_':
                value = getattr(module, key)
                setattr(self, key.lower(), value)
        setattr(self, f"setting_{module_name.split('.')[-1]}".lower(), module)

    def get(self, key, default=None):
        if hasattr(self, key):
            ret =  getattr(self, key)
        return default if ret is None else ret

    def __getattr__(self, key):
        if hasattr(Config, key):
            return getattr(Config, key)
        return None

config = Config()